﻿using EfInfra;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EfLearn
{
    public static class DI
    {
        public static IServiceProvider InsProvider { get; private set; }

        static DI()
        {
            Configure();
        }

        static void Configure()
        {
            var services = new ServiceCollection();

            //services.AddDbContext<OneToManyContext>((opt) =>
            //{
            //    string connStr= "Host=127.0.0.1;Port=5432;Database=eflearn;User ID=postgres;Password=sa*123;Pooling=true;MinPoolSize=10;MaxPoolSize=50;";
            //    opt.UseNpgsql(connStr);
            //    opt.LogTo(Console.WriteLine)
            //    .EnableSensitiveDataLogging();
            //});


            services.AddDbContext<MyContext>((opt) =>
            {
                string connStr = "Data Source=10.228.12.42:1521/pdbjyhx;User ID=jyhf1232;Password=jyhf1232;Max pool size=3;";
                opt.UseOracle(connStr);
                opt.LogTo(Console.WriteLine)
                .EnableSensitiveDataLogging();
            });

            InsProvider = services.BuildServiceProvider();
        }
    }
}
